package com.nowoe.aop.aspectj;

import java.lang.reflect.Method;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author 倚栏听风 2023/9/16 14:25
 */
public class AspectPointcut {
    private String expression;

    public String getExpression() {
        return expression;
    }

    public void setExpression(String expression) {
        this.expression = expression;
    }

    public boolean matches(Method method, Class<?> aClass) {
        String name = aClass.getPackageName() + "." + method.getName();
        Pattern pattern = Pattern.compile(expression);
        Matcher matcher = pattern.matcher(name);
        return matcher.matches();
    }
}
